
#include "bits/stdc++.h"
#include "eigen3/Eigen/Core"

// 构建线数据
template<typename scale>

class build_line_data
{
// y = Ax + b   x is 3*1   y is 3 * 1  A is 3*3   b is 3×1
private:
    typedef Eigen::Matrix<scale, 3, 3> M33;
    typedef Eigen::Matrix<scale, 3, 1> M31;

    M33 A;
    M31 b;
    M31 x;
    M31 y;

public:
    build_line_data(/* args */){
        A << 1., 2., 3., 4., 5., 6., 7., 8., 9.;
        b << 3., 2., 1.;
    }
    // 输出数据集数组   、  内点数量  、 外点数量
    void buid(std::vector<M31> & outXs, std::vector<M31> & outYs, size_t inlineNum, size_t outlineNum){
        
        outXs.clear();
        outXs.reserve(inlineNum + outlineNum);
        outYs.clear();
        outYs.reserve(inlineNum + outlineNum);
        // 生成内点数据

        std::uniform_real_distribution<double> u10(-10, 10);
        std::uniform_real_distribution<double> u1(-1, 1);
        std::default_random_engine e(time(NULL));


        for(size_t i = 0; i < inlineNum; ++i){
            x << u10(e), u10(e), u10(e);
            y = A * x  + b + M31(u1(e), u1(e), u1(e)) * 0.1;

            outXs.push_back(x);
            outYs.push_back(y);
        }

        // 生成外点数据
        for(size_t i = 0; i < outlineNum; ++i){
            x << u10(e), u10(e), u10(e);
            y = A * x + M31(u1(e), u1(e), u1(e)) * 2 + b;

            outXs.push_back(x);
            outYs.push_back(y);
        }
    }
    ~build_line_data(){}
};





